import { buildApiUrl } from '../config/api';

// 菜单相关API
export const menuApi = {
  // 获取用户菜单
  getSelfMenu: async () => {
    try {
      const response = await fetch(buildApiUrl('/security/sec-menu/self'), {
        method: 'GET',
        headers: {
          'Content-Type': 'application/json',
          'Authorization': `Bearer ${localStorage.getItem('authToken') || sessionStorage.getItem('authToken')}`
        }
      });

      if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
      }

      const data = await response.json();
      return data;
    } catch (error) {
      console.error('获取用户菜单失败:', error);
      throw error;
    }
  }
};
